<template>
    <div class="main-content f-cb">
      <div class="table_container">
        <el-table
          v-loading="tableLoading"
          :data="tableData"
          highlight-current-row
          style="width: 100%">
          <el-table-column
              type="index"
              width="100">
          </el-table-column>
          <el-table-column
              label="金额"
              width="220">
              <template slot-scope="scope">
                {{(scope.row.transAmount/100).toFixed(2)}}
              </template>
          </el-table-column>
          <el-table-column
              property="gmtCreate"
              label="时间"
              width="400">
          </el-table-column>
        </el-table>
        <div class="Pagination" style="text-align: left;margin-top: 10px;">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-size="limit"
            :page-count="10"
            layout="total, prev, pager, next"
            :total="count">
          </el-pagination>
        </div>
    </div>
  </div>
</template>

<script>
  import headTop from '@/components/headTop'
  import {adminGetAccountLog} from '@/api/points'
  export default {
    data () {
      return {
        tableData: [],
        currentRow: null,
        offset: 0,
        limit: 20,
        count: 0,
        currentPage: 1,
        tableLoading: false
      }
    },
    components: {
      headTop
    },
    mounted () {
      this.initData()
    },
    methods: {
      initData () {
        this.adminGetAccountLog(this.currentPage, this.limit)
      },
      async adminGetAccountLog (page, size) {
        // let d = {
        //   userAccountId: window.userId
        // }
        this.tableLoading = true

        let direction = this.$route.query.tab === 'deposit' ? 'IN' : 'OUT'
        let params = {
          pageIndex: page,
          pageSize: size,
          transDirection: direction,
          userName: this.$route.query.name
        }
        let result = await adminGetAccountLog(params)
        if (result.status === 200) {
          let data = result.data.data
          this.tableData = data
          this.count = result.data.page.total
        }
        this.tableLoading = false
      },
      handleCurrentChange (page) {
        console.log(page)
        this.currentPage = page
        this.adminGetAccountLog(this.currentPage, this.limit)
      },

      handleSizeChange (page) {
      }
    }
  }
</script>

<style lang="less" scoped>
    @import '../../style/mixin';
    .label-title{
        font-weight: bold;
        font-size: 24px;
        color: #ff633b;
        margin: 30px;
    }
    .main-content{
        padding: 0px 40px;
    }

</style>
